package com.xs.jmb2c.handlers;

import com.xs.jmb2c.common.Result;
import com.xs.jmb2c.exceptions.BusinessException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
// TODO 了解
@RestControllerAdvice
public class CommonExceptionalHandler {
    @ExceptionHandler(BusinessException.class)
    public Result handleException(BusinessException e) {
        return Result.error("-1",e.getMessage());
    }


    @ExceptionHandler(RuntimeException.class)
    public Result handleException(RuntimeException e) {
        return Result.error("-1",e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e) {
        return Result.error("-1",e.getMessage());
    }
}
